using NewFormatProject.Infrastructure.EFCore;
using NewFormatProject.Infrastructure.Dto.Responses.Objects;
using NewFormatProject.Repository.Instances;
using NewFormatProject.Server.EFCore;
using System.Linq;
namespace NewFormatProject.Server.Instances.Extends.Entitys
{
	public static class SysDepartmentsExtend
{
		public static ResponseSysDepartmentsDto ToResponseDto(this SysDepartments entity)
{			return new ResponseSysDepartmentsDto
			{
				id = entity.DId,
				name = entity.DName,
				description = entity.DDescription,
				parentId = entity.DParentId,
				parentName=new DepartmentServerEF(new Core2Context()).Query(d=>d.DId==entity.DParentId).SingleOrDefault()?.DName,
				createTime = entity.DCreateTime,
			};
		}
	}
}
